package com.example.demo.service.impl;

import com.example.demo.mapper.UserMapper;
import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public boolean login(User user) {
        int id = user.getId();   //将输入的用户名密码分别赋值

        System.out.println("service:"+id);
        String password = user.getPassword();
        User user1 = userMapper.findId(id);
        if (user1 != null) {     //如果查询结果不为空
            if (user1.getPassword().equals(password)) {       //密码比较
                return true;
            } else {
                return false;
            }
        }
        return false;
    }
}
